def add_book(library,title, author):
    book = f"{title}-{author}"
    if book in library:
        library[book] += 1
    else:
        library[book] = 1
    print("添加成功！")

def borrow_book(library,borrowed,title,user):
    for book in library:
        if title in book:
            if library[book]>0:
                library[book]-=1
                if user not in borrowed:
                    borrowed[user]=set()
                borrowed[user].add(book)
                print(f"《{title}》借阅成功！")
                return
    print(f"《{title}》无法借阅")

def return_book(library,borrowed,title,user):
    if user in borrowed:
        for book in borrowed[user]:
            if title in book:
                library[book]+=1
                borrowed[user].remove(book)
                if len(borrowed[user])==0:
                    del borrowed[user]
                print(f"《{title}》归还成功！")
                return
    print(f"用户{user}没有借阅《{title}》")

def show_status(library,borrowed):
    print("馆藏书籍：")
    if len(library) == 0:
        print("  无")
    else:
        for book, count in library.items():
            print(f"  {book}:{count}本")

    print("\n借阅记录：")
    if len(borrowed)==0:
        print("  无")
    else:
        for user, books in borrowed.items():
            print(f"  {user}: {', '.join(books)} ({len(books)}本)")

def main():
    library = {}
    borrowed = {}

    show_status(library, borrowed)

    add_book(library, "Python编程", "abc")
    add_book(library, "数据结构", "def")
    add_book(library, "算法导论", "ghi")

    show_status(library, borrowed)

    add_book(library, "Python编程", "abc")
    add_book(library, "数据结构", "def")
    add_book(library, "算法导论", "ghi")

    show_status(library, borrowed)

    borrow_book(library, borrowed, "Python编程", "张三")
    borrow_book(library, borrowed, "数据结构", "李四")

    show_status(library, borrowed)

    add_book(library, "高等数学", "sdf")
    add_book(library, "大学物理", "fgd")
    add_book(library, "大学英语", "erf")

    show_status(library, borrowed)

    return_book(library, borrowed, "Python编程", "张三")

    borrow_book(library, borrowed, "算法导论", "王五")

    show_status(library,borrowed)

main()